/*
 * LogEx a Java library for extracting log file data
 * Copyright 2012 LogEx Team.
 *
 * This program is free software. You can distribute or modify it under the 
 * terms of the GNU Lesser General Public License version 3.0 as published by  
 * the Free Software Foundation.
 *
 * This program is distributed AS IS and WITHOUT WARRANTY. OF ANY KIND,
 * INCLUDING MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, contact the Free Software Foundation, Inc.,
 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
package org.logex.main;

/**
 * Maintains String constants used in the project code. Maps SDL keywords with actual symbols.
 * 
 * @author Lohitha Chiranjeewa
 */
public class StringConstants {
	
	private static final String SPACE = "SPACE";
	private static final String EOL = "EOL";
	private static final String TAB = "TAB";
	private static final String LEFT_SQUARE_BRACKET = "LSQR";
	private static final String RIGHT_SQUARE_BRACKET = "RSQR";
	private static final String DOUBLE_QUOTES = "DBQTS";
	private static final String COLON = "CLN";
	private static final String SEMI_COLON = "SMCLN";
	private static final String APOSTROPHE = "APOS";
	private static final String COMMA = "COMMA";
	public static final String XML_EXTENSION = ".xml";
	public static final String DELIMITER = "delimiter";
	public static final String REQUIRED = "required";
	public static final String STARTS_NOT_REQ = "startsNotRequired";
	public static final String ENDS_NOT_REQ = "endsNotRequired";
	public static final String FIXED_VAL = "fixedValue";
	public static final String TITLE = "title";
	public static final String LOGEX_TEAM_MSG = "LogEx team 2012";
	public static final String SDL_FOLDER_NAME = "sdl";
	public static final String USER_DIR = "user.dir";
	public static final String USER_HOME = "user.home";
	public static final String LOG_FILE_START_TAG = "<Log>";
	public static final String LOG_FILE_END_TAG = "</Log>";
	public static final String NOTICE_START_TAG = "<LogExNotice>";
	public static final String NOTICE_END_TAG = "</LogExNotice>";
	public static final String ENTRY_BUNDLE_START_TAG = "<EntryBundle>";
	public static final String ENTRY_BUNDLE_END_TAG = "</EntryBundle>";
	public static final String UNID_LINE_START_TAG = "<UnidentifiedLine>";
	public static final String UNID_LINE_END_TAG = "</UnidentifiedLine>";
	
	/**
	 * Matches the incoming delimiting keyword to the actual character.
	 * 
	 * @param delimiter The delimiting keyword from the SDL script
	 * @return The corresponding delimiting character
	 */
	public static String getDelimiterChar(String delimiter){
		if(delimiter.equals(SPACE)){
			return " ";
		}
		else if(delimiter.equals(EOL)){
			return "\n";
		}
		else if(delimiter.equals(TAB)){
			return "\t";
		}
		else if(delimiter.equals(COLON)){
			return ":";
		}
		else if(delimiter.equals(SEMI_COLON)){
			return ";";
		}
		return delimiter;
	}
	
	/**
	 * Matches the incoming edge-of-the-line keyword to the actual character.
	 * 
	 * @param edge The edge-of-the-line keyword from the SDL script
	 * @return The corresponding edge-of-the-line character
	 */
	public static String getEdgeChar(String edge){
		if(edge.equals(LEFT_SQUARE_BRACKET)){
			return "[";
		}
		else if(edge.equals(RIGHT_SQUARE_BRACKET)){
			return "]";
		}
		else if(edge.equals(DOUBLE_QUOTES)){
			return "\"";
		}
		else if(edge.equals(COLON)){
			return ":";
		}
		else if(edge.equals(SEMI_COLON)){
			return ";";
		}
		else if(edge.equals(APOSTROPHE)){
			return "'";
		}
		else if(edge.equals(SPACE)){
			return " ";
		}
		else if(edge.equals(TAB)){
			return "	";
		}
		else if(edge.equals(COMMA)){
			return ",";
		}
		else
			return edge;
	}
	
	
}
